package com.wmwj.hxlj.controller;

import com.wmwj.hxlj.entity.Article;
import com.wmwj.hxlj.entity.Collection;
import com.wmwj.hxlj.entity.vo.ArticleVo;
import com.wmwj.hxlj.entity.vo.PageResult;
import com.wmwj.hxlj.service.CollectionService;
import com.wmwj.hxlj.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/collection")
public class CollectionController {
    //TODO: 收藏夹相关接口

    @Autowired
    private CollectionService collectionService;

    //收藏文章
    @RequestMapping("/add")
    public Result<Integer> add(@RequestBody Collection collection){
        return collectionService.add(collection);
    }

    //通过用户id和文件夹查询所有已收藏收藏文章
    @RequestMapping("/getCollection")
    public Result<PageResult<ArticleVo>> getCollection(
            @RequestParam Long userId,
            @RequestParam Long collectionId,
            @RequestParam(defaultValue = "1") Integer page ){
        return collectionService.getCollection(userId,collectionId,page);
    }
}
